/**
 * 
 */
package com.thor.palmmall.rest.chart.converter;

import org.springframework.core.convert.converter.Converter;

import com.thor.commons.util.ConverterUtil;
import com.thor.palmmall.rest.chart.ARentalReport;
import com.thor.palmmall.spi.chart.SRentalReport;

/**
 * @author NuoSa
 *
 * @since 1.0
 */
public class ARentalReportConverter implements Converter<SRentalReport, ARentalReport> {

  public static ARentalReportConverter getInstance() {
    if (instance == null)
      instance = new ARentalReportConverter();
    return instance;
  }

  private static ARentalReportConverter instance;

  private ARentalReportConverter() {
  }

  @Override
  public ARentalReport convert(SRentalReport source) {
    if (source == null) {
      return null;
    }
    ARentalReport target = new ARentalReport();
    target.setArea(source.getArea());
    target.setRate(source.getRate());
    target.setRentals(ConverterUtil.convert(source.getRentals(), ARentalConverter.getInstance()));
    target.setRentArea(source.getRentArea());
    return target;
  }

}
